﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using jQueryDemo.DataAccess.DataSet.ServiceCategoryTableAdapters;
using System.Data;

namespace jQueryDemo.BusinessObject.Entity
{
    public class Service : BusinessObjectBase
    {
        #region Properties
        public string Name { get; set; }
        public string Code { get; set; }
        [ReflectionIgnored]
        public int ServiceCategoryId { get; set; }
        #endregion

        #region Fields
        private ServiceTableAdapter TableAdapter
        {
            get { return new ServiceTableAdapter(); }
        }
        #endregion

        public override void Load()
        {
            throw new NotImplementedException();
        }

        public override void Insert()
        {
            throw new NotImplementedException();
        }

        public override void Update()
        {
            throw new NotImplementedException();
        }

        public override void Delete()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Load all services of a service category
        /// </summary>
        /// <returns></returns>
        public Service[] LoadAll()
        {
            List<Service> allServices = new List<Service>();

            DataTable dtServices = TableAdapter.GetAllServices(ServiceCategoryId);
            foreach (DataRow row in dtServices.Rows)
            {
                Service sev = new Service();
                sev.LoadRow(row);
                allServices.Add(sev);
            }

            return allServices.ToArray();
        }
    }
}
